<?php


namespace App\Http\Search\Order;


use LTools\Searchs\SearchAbstract;

class ListIndexSearch extends SearchAbstract
{

    /**
     * 关系映射.
     *
     * @return array
     */
    protected function relationship(): array
    {
        return [
            'order_code' => '=',
            'status' => '=',
            'updated_at' => 'closure'
        ];
    }

    /**
     * @param $value
     * @return \Closure
     * @author luffyzhao@vip.126.com
     */
    protected function getUpdatedAtAttribute($value)
    {
        return function ($query) use ($value) {
            if (count($value) === 2 && !empty($value[0]) && !empty($value[1])) {
                $query->whereBetween('updated_at', $value);
            }
        };
    }
}